package com.kh.pajx.sop.view.action;

import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.kh.pajx.sop.base.SOPConfig;
import com.kh.pajx.sop.domain.SysDepartment;
import com.kh.pajx.sop.domain.SysInsideUser;
import com.kh.pajx.sop.service.sys.ISysDepartmentService;
import com.kh.pajx.sop.service.user.ISysInsideUserService;
import com.kh.pajx.sop.util.common.DwzAjaxResult;
import com.kh.pajx.sop.util.common.FormatDate;
import com.kh.pajx.sop.util.common.ValidatorUtils;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

/**
 * 业务统计Action类
 * @author mxl
 * @createDate 2014年9月18日 上午9:27:14
 */

@Controller
@Scope("prototype")
@SuppressWarnings("serial")
public class BusinessReport extends ActionSupport{
	@Resource
	private ISysInsideUserService sysInsideUserService;
	@Resource
	protected ISysDepartmentService sysDepartmentService;
	/** 用来接收存储报表文件名称(set时不能有后缀名) */
	private String reportFileName;
	private boolean hasParamFile;
	private String currentMethod;
	
	
	/**移动行业经理季度结算报表统计*/
	public String ydRpt(){
		try {
			setReportFileName("yw_rpt_areamanger_back");
			setCurrentMethod("ydRpt");
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	/**业务结算明细*/
	@Deprecated
	public String ydRptDetail(){
		try {
			setReportFileName("yw_rpt_areamanger_detail");
			setCurrentMethod("ydRptDetail");
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	/**业务人员销售提成统计*/
	@Deprecated
	public String saleData(){
		try {
			setReportFileName("yw_rpt_business_back");
			setCurrentMethod("saleData");
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	/**业务人员销售提成统计明细*/
	@Deprecated
	public String saleDataDetail(){
		try {
			setReportFileName("yw_rpt_business_detail");
			setCurrentMethod("saleDataDetail");
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	/** 对外结算统计 */
	@Deprecated
	public String outData(){
		try {
			setReportFileName("yw_rpt_foreign_back");
			setCurrentMethod("outData");
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	/** 部门业务月增量统计 */
	@Deprecated
	public String monthData(){
		try {
			setReportFileName("yw_rpt_graph_month");
			setCurrentMethod("monthData");
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	/**套餐开通对比分析*/
	public String taocan(){
		try {
			setReportFileName("yw_rpt_graph_opentype");
			setCurrentMethod("taocan");
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	public String graphProgress(){
		return "toGraphProgress";
	}
	
	/**业务开通情况走势图*/
	public String usergraph(){
		try {
			setReportFileName("yw_rpt_graph_progress");
			setCurrentMethod("usergraph");
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	
	
	/**学校开通率Ui*/
	public String schoolKTLUi(){
		return "schoolKTLUi";
	}
	
	
	/**统计学校开通率*/
	public String schoolKtl(){
		try {
			HttpServletRequest request = ServletActionContext.getRequest();
			// ==> 1.前端参数获取
			String flag = request.getParameter("rptflag");//统计类型
			String enddate = request.getParameter("enddate");//统计日期
			String areaCode = request.getParameter("areaCode");//地区
			String cityCode = request.getParameter("cityCode");//县区
			
			// ==> 2.输入参数校验
			if(!ValidatorUtils.validateFixedLengthNumber(flag, 1, false)){
				throw new Exception("检索条件[统计类型]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateDateYYYYMMDD(enddate, false)){
				throw new Exception("检索条件[统计日期]不符合规范，非法参数提交！");
			}
			if(!areaCode.equals("0")){
				if(!ValidatorUtils.validateFixedLengthNumber(areaCode, 4, false)){
					throw new Exception("检索条件[地区]不符合规范，非法参数提交！");
				}
			}
			
			if(!cityCode.equals("0")){
				if(!ValidatorUtils.validateFixedLengthNumber(cityCode, 6, true)){
					throw new Exception("检索条件[县区]不符合规范，非法参数提交！");
				}
			}
			
			String tjdate="";
			if("0".equals(flag)){
				// 月统计
				tjdate = enddate.substring(0, 7);
			}else if("1".equals(flag)){
				// 周统计
				tjdate = FormatDate.getWeekScope(enddate);
			}else{
				throw new Exception("检索条件[统计类型]无法识别，非法参数提交！");
			}
			
			
			setReportFileName("yw_rpt_school_searchp");
			setCurrentMethod("schoolKtl");
			
			// 封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("report_flag", flag);
			params.put("end_date", FormatDate.getMarryTime(enddate));
			params.put("tj_date", tjdate);
			params.put("cityCode", StringUtils.isBlank(cityCode)?"0":cityCode);
			
			
			ActionContext.getContext().put("params", params);
			
			return "toShowReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	/**拓展人员半年提成统计ui*/
	public String exteUi(){
		//准备大区信息
		List<SysDepartment> dptList = sysDepartmentService.findChildrenDepartment(SOPConfig.CODE_DEPT_SALE);
		ActionContext.getContext().put("dptList", dptList);
		// 准备扩展人员
		List<SysInsideUser> saleList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_ROLE_EXTEND,1);
		ActionContext.getContext().put("saleList", saleList);
		return "exteUi";
	}
	/**拓展人员半年提成统计*/
	public String exte(){
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_sale_id=request.getParameter("exte_saleId");
			String v_enddate = request.getParameter("exte_enddate");
			//输入参数校验
			if(!ValidatorUtils.validateUUID(v_sale_id, true)){
				throw new Exception("检索条件[拓展人员]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateFixedLengthNumber(v_enddate, 8, false)){
				throw new Exception("检索条件[统计时间]不符合规范，非法参数提交！");
			}
			
			setReportFileName("yw_bal_exte_halfyear");
			setCurrentMethod("exte");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("V_SALE_ID", v_sale_id);
			params.put("V_ENDDATE", v_enddate);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
		
	}
	/**维护人员半年提成统计Ui*/
	public String keepYearUi(){
		//准备大区信息
		List<SysDepartment> dptList = sysDepartmentService.findChildrenDepartment(SOPConfig.CODE_DEPT_SALE);
		ActionContext.getContext().put("dptList", dptList);
		// 准备维护人员
		List<SysInsideUser> maintainList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_GROUP_MAINTAIN,1);
		ActionContext.getContext().put("maintainList", maintainList);
		return "keepYearUi";
	}
	/**维护人员半年提成统计*/
	public String keepYear(){
		
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_keep_id=request.getParameter("saleIdkeepYear");
			String v_enddate = request.getParameter("enddatekeepYear");
			//输入参数校验
			if(!ValidatorUtils.validateUUID(v_keep_id, true)){
				throw new Exception("检索条件[拓展人员]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateFixedLengthNumber(v_enddate, 8, false)){
				throw new Exception("检索条件[统计时间]不符合规范，非法参数提交！");
			}
			
			setReportFileName("yw_bal_keep_halfyear");
			setCurrentMethod("keepYear");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("V_KEEP_ID", v_keep_id);
			params.put("V_ENDDATE", v_enddate);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	/**维护人员月度提成统计UI*/
	public String keepUi(){
		//准备大区信息
		List<SysDepartment> dptList = sysDepartmentService.findChildrenDepartment(SOPConfig.CODE_DEPT_SALE);
		ActionContext.getContext().put("dptList", dptList);
		// 准备维护人员
		List<SysInsideUser> maintainList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_GROUP_MAINTAIN,1);
		ActionContext.getContext().put("maintainList", maintainList);
		return "keepUi";
	}
	/**维护人员月度提成统计*/
	public String keep(){
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_sale_id=request.getParameter("keep_saleId");
			String v_enddate = request.getParameter("keep_enddate");
			//输入参数校验
			if(!ValidatorUtils.validateUUID(v_sale_id, true)){
				throw new Exception("检索条件[维护人员]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateFixedLengthNumber(v_enddate, 8, false)){
				throw new Exception("检索条件[统计时间]不符合规范，非法参数提交！");
			}
			
			setReportFileName("yw_bal_keep_month");
			setCurrentMethod("keep");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("V_SALE_ID", v_sale_id);
			params.put("V_ENDDATE", v_enddate);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
		
	}
	
	public String keepMonthDetail(){
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_sale_id=request.getParameter("v_sale_id");
			String v_enddate = request.getParameter("v_enddate");
			String v_sale_name = request.getParameter("v_sale_name");
			//输入参数校验
			if(!ValidatorUtils.validateUUID(v_sale_id, true)){
				throw new Exception("检索条件[维护人员]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateFixedLengthNumber(v_enddate, 8, false)){
				throw new Exception("检索条件[统计时间]不符合规范，非法参数提交！");
			}
			setReportFileName("yw_bal_keep_month_detail");
			setCurrentMethod("keepMonthDetail");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("v_sale_id", v_sale_id);
			params.put("v_enddate", v_enddate);
			params.put("v_sale_name", v_sale_name);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	
	/**总体运行分析日报UI*/
	public String graphDayUi(){
		//准备大区信息
		List<SysDepartment> dptList = sysDepartmentService.findChildrenDepartment(SOPConfig.CODE_DEPT_SALE);
		ActionContext.getContext().put("dptList", dptList);
		// 准备扩展人员
		List<SysInsideUser> saleList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_ROLE_EXTEND,1);
		ActionContext.getContext().put("saleList", saleList);
		return "graphDayUi";
	}
	/**根据所属大区获取拓展人员*/
	public String getExte(){
		HttpServletRequest request = ServletActionContext.getRequest();
		DwzAjaxResult result = new DwzAjaxResult();
		String deptCode= request.getParameter("deptCode");
		// 准备扩展人员
		List<SysInsideUser> saleUserList=null;
		if(StringUtils.isNotBlank(deptCode)){
			saleUserList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_ROLE_EXTEND,1,deptCode);
		}else{
			saleUserList =sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_ROLE_EXTEND,1);
		}
		
		ActionContext.getContext().put("saleUserList", saleUserList);
		return "getExte";
	}
	/**总体运行分析日报*/
	public String graphDay(){
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_dept_id=request.getParameter("deptId");
			String v_sale_id = request.getParameter("saleId");
			//输入参数校验
			if(!ValidatorUtils.validateFixedLengthNumber(v_dept_id, 4, true)){
				throw new Exception("检索条件[所属大区]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateUUID(v_sale_id, true)){
				throw new Exception("检索条件[拓展人员]不符合规范，非法参数提交！");
			}
			
			
			setReportFileName("yw_graph_total_day");
			setCurrentMethod("graphDay");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("v_dept_id", v_dept_id);
			params.put("v_sale_id", v_sale_id);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	/**总体运行分析月报UI*/
	public String graphMonthUi(){
		//准备大区信息
		List<SysDepartment> dptList = sysDepartmentService.findChildrenDepartment(SOPConfig.CODE_DEPT_SALE);
		ActionContext.getContext().put("dptList", dptList);
		// 准备扩展人员
		List<SysInsideUser> saleList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_ROLE_EXTEND,1);
		ActionContext.getContext().put("saleList", saleList);
		return "graphMonthUi";
	}
	/**总体运行分析月报*/
	public String graphMonth(){
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_dept_id=request.getParameter("deptIdMonth");
			String v_sale_id = request.getParameter("saleIdMonth");
			//输入参数校验
			if(!ValidatorUtils.validateFixedLengthNumber(v_dept_id, 4, true)){
				throw new Exception("检索条件[所属大区]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateUUID(v_sale_id, true)){
				throw new Exception("检索条件[拓展人员]不符合规范，非法参数提交！");
			}
			
			
			setReportFileName("yw_graph_total_month");
			setCurrentMethod("graphMonth");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("v_dept_id", v_dept_id);
			params.put("v_sale_id", v_sale_id);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
		
	}
	/**总体运行分析周报UI*/
	public String graphWeekUi(){
		//准备大区信息
		List<SysDepartment> dptList = sysDepartmentService.findChildrenDepartment(SOPConfig.CODE_DEPT_SALE);
		ActionContext.getContext().put("dptList", dptList);
		// 准备扩展人员
		List<SysInsideUser> saleList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_ROLE_EXTEND,1);
		ActionContext.getContext().put("saleList", saleList);
		return "graphWeekUi";
	}
	/**总体运行分析周报*/
	public String graphWeek(){
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_dept_id=request.getParameter("deptIdWeek");
			String v_sale_id = request.getParameter("saleIdWeek");
			//输入参数校验
			if(!ValidatorUtils.validateFixedLengthNumber(v_dept_id, 4, true)){
				throw new Exception("检索条件[所属大区]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateUUID(v_sale_id, true)){
				throw new Exception("检索条件[拓展人员]不符合规范，非法参数提交！");
			}
			
			
			setReportFileName("yw_graph_total_week");
			setCurrentMethod("graphWeek");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("v_dept_id", v_dept_id);
			params.put("v_sale_id", v_sale_id);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
		
	}
	/**拓展人员辖内学校开通状况日报UI*/
	public String exteDayUi(){
		//准备大区信息
		List<SysDepartment> dptList = sysDepartmentService.findChildrenDepartment(SOPConfig.CODE_DEPT_SALE);
		ActionContext.getContext().put("dptList", dptList);
		// 准备扩展人员
		List<SysInsideUser> saleList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_ROLE_EXTEND,1);
		ActionContext.getContext().put("saleList", saleList);
		return "exteDayUi";
	}
	/**拓展人员辖内学校开通状况日报*/
	public String exteDay(){
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_dept_id=request.getParameter("deptIdExte");
			String v_sale_id = request.getParameter("saleIdExte");
			String v_enddate = request.getParameter("enddateExte");
			
			//输入参数校验
			if(!ValidatorUtils.validateFixedLengthNumber(v_dept_id, 4, true)){
				throw new Exception("检索条件[所属大区]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateUUID(v_sale_id, true)){
				throw new Exception("检索条件[拓展人员]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateFixedLengthNumber(v_enddate, 8, false)){
				throw new Exception("检索条件[统计时间]不符合规范，非法参数提交！");
			}
			
			setReportFileName("yw_rpt_total_extend_day");
			setCurrentMethod("exteDay");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("V_DEPT_ID", v_dept_id);
			params.put("V_SALE_ID", v_sale_id);
			params.put("V_ENDDATE", v_enddate);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	/**维护人员辖内学校开通状况日报UI*/
	public String keepDayUi(){
		//准备大区信息
		List<SysDepartment> dptList = sysDepartmentService.findChildrenDepartment(SOPConfig.CODE_DEPT_SALE);
		ActionContext.getContext().put("dptList", dptList);
		// 准备维护人员
		List<SysInsideUser> maintainList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_GROUP_MAINTAIN,1);
		ActionContext.getContext().put("maintainList", maintainList);
		return "keepDayUi";
	}
	/**根据所属大区获取维护人员*/
	public String getKeep(){
		HttpServletRequest request = ServletActionContext.getRequest();
		DwzAjaxResult result = new DwzAjaxResult();
		String deptCode= request.getParameter("deptCode");
		// 准备维护人员
		List<SysInsideUser> keepUserList=null;
		if(StringUtils.isNotBlank(deptCode)){
			keepUserList = sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_GROUP_MAINTAIN,1,deptCode);
		}else{
			keepUserList =sysInsideUserService.getUserByRoleCode(SOPConfig.CODE_USER_GROUP_MAINTAIN,1);
		}
		
		ActionContext.getContext().put("keepUserList", keepUserList);
		return "getKeep";
	}
	/**维护人员辖内学校开通状况日报*/
	public String keepDay(){
		try{
			HttpServletRequest request = ServletActionContext.getRequest();
			// 前端参数获取
			String v_dept_id=request.getParameter("deptIdKeep");
			String v_sale_id = request.getParameter("saleIdKeep");
			String v_enddate = request.getParameter("enddateKeep");
			
			//输入参数校验
			if(!ValidatorUtils.validateFixedLengthNumber(v_dept_id, 4, true)){
				throw new Exception("检索条件[所属大区]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateUUID(v_sale_id, true)){
				throw new Exception("检索条件[拓展人员]不符合规范，非法参数提交！");
			}
			if(!ValidatorUtils.validateFixedLengthNumber(v_enddate, 8, false)){
				throw new Exception("检索条件[统计时间]不符合规范，非法参数提交！");
			}
			
			setReportFileName("yw_rpt_total_keep_day");
			setCurrentMethod("keepDay");
			//封装报表特有参数
			Map<String,String> params = new HashMap<String,String>();
			params.put("V_DEPT_ID", v_dept_id);
			params.put("V_SALE_ID", v_sale_id);
			params.put("V_ENDDATE", v_enddate);
			
			ActionContext.getContext().put("params", params);
			return "toShowReport";
		}catch(Exception e){
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	/** 通用报表展示页面 */
	public String showReport(){
		try {
			// ==> 1.页面提交参数使用HTTPServletRequest方式获取
			Map<String, String[]> paramsMap = ServletActionContext.getRequest().getParameterMap();
			Map<String,String> reportParamMap = (Map<String,String>)ActionContext.getContext().get("params");
			System.out.println(paramsMap.size());
			// ==> 2.构建report查询参数
			StringBuffer paramsStr = new StringBuffer(); 
			for (Map.Entry<String, String[]> entry : paramsMap.entrySet()) {
				String value = "";
				Object valueObj = entry.getValue();
				if(null == valueObj){
					value = "";
				}else if(valueObj instanceof String[]){
					String[] values = (String[])valueObj;
				    for(int i=0; i<values.length; i++){
				    	value = values[i] + ",";
				    }
				    value = value.substring(0, value.length()-1);
				}else{
				    value = valueObj.toString();
				}
				
				if(StringUtils.isNotBlank(value)){
					paramsStr.append(entry.getKey()).append("=").append(value).append(";");
				}
			 }
			System.out.println(paramsStr.toString());
			if(reportParamMap!=null && reportParamMap.size()>0){
				for (Map.Entry<String, String> entry : reportParamMap.entrySet()) {
					if(entry.getValue() != null){
						paramsStr.append(entry.getKey()).append("=").append(entry.getValue()).append(";");
					}
				}
			}
			
			// ==> 3.检验report自身是否含有参数文件
			String realPath = ServletActionContext.getServletContext().getRealPath(File.separator);
			
			File reportParamFile = new File(realPath + "WEB-INF" + File.separator + "report" + File.separator + "reportFiles"
						+File.separator + getReprotParamFileName());
			
			setHasParamFile(reportParamFile.exists() ? true : false);
			
			
			// ==> 4.封装页面显示用参数
			ActionContext.getContext().put("raqname", getReportFileName()+".raq");
			ActionContext.getContext().put("raqParamName", getReprotParamFileName());
			ActionContext.getContext().put("params", paramsStr.toString());
			System.out.println("=======================================");
			System.out.println(paramsStr.toString());
			/*System.out.println("request get map siz :"+ServletActionContext.getRequest().getParameterMap().size());
			Map<String,String> paramMmap = (Map<String,String>)ActionContext.getContext().get("params");
			String raqname = paramMmap.get("raqname");
			
			
			
			// 开始拼接参数
			StringBuffer paramsStr = new StringBuffer();
			 for (Map.Entry<String, String> entry : paramMmap.entrySet()) {
				 if(!entry.getKey().equals("raqname")){
					 if(entry.getValue() != null){
						 paramsStr.append(entry.getKey()).append("=").append(entry.getValue()).append(";");
					 }
				 }
			 }
			
			 // 检查是否有参数文件
			String paramRaq = raqname + "_arg.raq";
			String realPath = ServletActionContext.getServletContext().getRealPath(File.separator);
			File paramFile = new File(realPath+"WEB-INF"+File.separator+"report"+File.separator+"reportFiles"+File.separator+paramRaq);
			boolean showParamPage = false;
			if(paramFile.exists()){
				showParamPage = true;
			}
			ActionContext.getContext().put("raqname", raqname+".raq");
			ActionContext.getContext().put("paramRaq", paramRaq);
			ActionContext.getContext().put("showParamPage", showParamPage);
			ActionContext.getContext().put("params", paramsStr.toString());*/
			return "showReport";
		} catch (Exception e) {
			e.printStackTrace();
			ActionContext.getContext().put("errorMsg", e.getMessage());
			return "error";
		}
	}
	
	
	// =================================================================================================
	
	public String getReportFileName() {
		return reportFileName;
	}
	
	public void setReportFileName(String reportFileName) {
		this.reportFileName = reportFileName;
	}
	
	public boolean isHasParamFile() {
		return hasParamFile;
	}
	
	public void setHasParamFile(boolean hasParamFile) {
		this.hasParamFile = hasParamFile;
	}
	
	public String getCurrentMethod() {
		return currentMethod;
	}
	public void setCurrentMethod(String currentMethod) {
		this.currentMethod = currentMethod;
	}
	
	// =================================================================================================
	
	
	private String getReprotParamFileName() {
		if(StringUtils.isNotBlank(getReportFileName())){
			return getReportFileName() + "_arg.raq";
		}
		return "";
	}
	
	
}
